#include "StdAfx.h"
#include "CancellationRepository.h"

// CancellationRepository::CancellationRepository(sqlite3x::connection& dbConnection)
// :m_dbConnection(dbConnection)
// {
// }

CancellationRepository::CancellationRepository()
{
}

CancellationRepository::~CancellationRepository(void)
{
}

Cancellation& CancellationRepository::Save(Cancellation const& cancellation)
{
	std::map<int,Cancellation>::iterator iter = m_cancellations.find(cancellation.GetKey());
	if (iter == m_cancellations.end())
	{
		iter = m_cancellations.insert(std::make_pair(cancellation.GetKey(),cancellation)).first;
	}
	Cancellation& savedCancellation = iter->second;
	savedCancellation = cancellation;
	return savedCancellation;
}

Cancellation const* CancellationRepository::Get(int localId) const
{
	std::map<int,Cancellation>::const_iterator iter = m_cancellations.find(localId);
	if (iter == m_cancellations.end())
	{
		return NULL;
	}
	return &iter->second;
}